//购物车的点击事件
function shopping_click() {
    var register =  document.getElementById("top2_a").getAttribute("name");
    alert(register);
    if (register.trim().length==0){
        window.location.href = "/MyXiaomiShop/login.jsp";
    }else {
        window.location.href = "/MyXiaomiShop/cart.jsp";
    }
}

function confirm_payment() {
    var order_number = document.getElementById("order_number").value;
    var payment_amount = document.getElementById("payment_amount").value;
    var total_prices = document.getElementById("total_prices").value;
    var prices = total_prices.substring(0,total_prices.length-1);

    if (parseInt(payment_amount) <= 0 || payment_amount == ""){
        document.getElementById("hint").innerText = "请输入你的要付款金额！！";
    }else if (parseInt(payment_amount)<parseInt(prices)){
        document.getElementById("hint").innerText = "你输入的金额无法购买当前的订单！！";
    }else {
        document.getElementById("hint").innerText = "";
        //跳转到支付成功的页面
        //并把当前订单的状态改为以支付未发货的状态
            $(function () {
                $.ajax({
                    url: "payWeixinUpdateState?&order_number=" + order_number,
                    type: "get",
                    dataType: "json",
                    success: function (res) {
                        if (res){
                            window.location.href = "/MyXiaomiShop/message.jsp";
                        }
                    },
                    error: function (res) {
                        alert("所有购物车获取失败！")
                    }
                });
            });
        }
}